﻿@model cloudscribe.Core.Web.ViewModels.CoreData.GeoCountryViewModel
@inject ICoreThemeHelper themeHelper
@inject IStringLocalizer<CloudscribeCore> sr
@{
    var themeSettings = themeHelper.GetThemeSettings();
    if (themeSettings.AdminSideNavExpanded) { ViewData["SideNavToggle"] = "show"; }
    ViewData["SideNavVisible"] = true;
}

<h2>@ViewData["Title"]</h2>
<form role="form" asp-controller="CoreData" asp-action="CountryEdit" data-submit-once="true">
    <div asp-validation-summary="All" class="text-danger"></div>
    <input asp-for="Id" type="hidden" />
    <div class="mb-3">
        <label class="form-label" asp-for="Name">@sr["Name"]</label>
        <input asp-for="Name" class="form-control" />
        <span asp-validation-for="Name" class="invalid-feedback"></span>
    </div>
    <div class="mb-3">
        <label class="form-label" asp-for="ISOCode2">@sr["ISOCode2"]</label>
        <input asp-for="ISOCode2" class="form-control" />
        <span asp-validation-for="ISOCode2" class="invalid-feedback"></span>
    </div>
    <div class="mb-3">
        <label class="form-label" asp-for="ISOCode3">@sr["ISOCode3"]</label>
        <input asp-for="ISOCode3" class="form-control" />
        <span asp-validation-for="ISOCode3" class="invalid-feedback"></span>
    </div>
    <div class="mb-3">
        <a class="btn btn-primary" asp-action="CountryListPage" asp-route-pagenumber="@Model.ReturnPageNumber">@sr["Back To Country List"]</a>
        <button name="submit" type="submit" class="btn btn-primary" data-enabled-text='@sr["Save"]' data-disabled-text='@sr["Working..."]'>@sr["Save"]</button>
        @if (Model.Id != Guid.Empty)
        {
            <button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#confirmDeleteModal">
                @sr["Delete"]
            </button>
        }
    </div>
</form>
@if (Model.Id != Guid.Empty)
{
    <form id="deleteform" asp-controller="CoreData" asp-action="CountryDelete">
        <input type="hidden" id="countryId" name="countryId" value="@Model.Id" />
        <input type="hidden" asp-for="ReturnPageNumber" />
        <div class="modal fade" id="confirmDeleteModal" tabindex="-1" role="dialog" aria-labelledby="confirmDeleteHeading">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title" id="confirmDeleteHeading">@sr["Confirm Delete"]</h4>
                        <button type="button" data-bs-dismiss="modal" class="btn-close" aria-label='@sr["Close"]'></button>
                    </div>
                    <div class="modal-body">
                        @string.Format(sr["Are you sure you want to delete the country {0} and all of its states? You cannot undo this action."], Model.Name)
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" data-bs-dismiss="modal">@sr["Cancel"]</button>
                        <input type="submit" value='@sr["Delete"]' class="btn btn-danger btn-ok" />
                    </div>
                </div>
            </div>
        </div>
    </form>
}


@section SideNav {
    <partial name="AdminSideNav" />
}
@section Toolbar{
    <partial name="AdminSideNavToggle" />
}
@section scripts {
    <partial name="AdminSideNavScripts" />
    <script src="~/cr/js/jquery.validate.min.js"></script>
    <script src="~/cr/js/jquery.validate.unobtrusive.min.js"></script>
    <script src="~/cr/js/unobtrusive-validation-bs4.min.js"></script>
    <script src="~/cr/js/jquery.validate.hooks.min.js"></script>
    <script src="~/cr/js/jqueryvaildation.submitonce-unobtrusive.min.js"></script>
}


